
figure()

xmin=1;
xmax=29;

U_h1=P(1:xmin,1);
P_h1=P(1:xmin,2);
P_diff1=P(1:xmin,6);

U_h=P(xmin:xmax,1);
P_h=P(xmin:xmax,2);
P_diff=P(xmin:xmax,6);

U_h2=P(xmax:end,1);
P_h2=P(xmax:end,2);
P_diff2=P(xmax:end,6);

U_h3=[U_h1;U_h2];
P_h3=[P_h1;P_h2];
P_diff3=[P_diff1;P_diff2];

coeffs=polyfit(U_h,P_diff,1);

plot(U_h,P_h,'ko')
hold on;
plot(U_h,P_diff,'x')
plot([0 max(U_h)],polyval(coeffs,[0 max(U_h)]),'--');
grid on;
xlabel('U_{h,1}^2 in V^2')
ylabel('P in W')

%plot(U_h3,P_h3,'ro')
%plot(U_h3,P_diff3,'rx')

axis([0 max(U_h)+500 0 max(P_h2)+50]);

 plot1=[U_h,P_h];
 plot2=[U_h,P_diff];
 plot3=[[0;max(U_h)],polyval(coeffs,[0;max(U_h)])];
 
% plot4=[U_h3,P_h3]
% plot5=[U_h3,P_diff3]